import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, Matches, IsString } from 'class-validator';
import { regMobileCN } from '@/shared/utils/regex.util';

export class RegisterSMSDto {
  /**
   * 手机号（系统唯一）
   */
  @Matches(regMobileCN, { message: '请输入正确手机号' })
  @IsNotEmpty({ message: '请输入手机号' })
  @ApiProperty({ example: '18715147473', description: '手机号' })
  readonly phoneNumber: string;

  /**
   * 短信验证码
   */
  @IsNotEmpty({ message: '请输入验证码' })
  @ApiProperty({ example: '0000', description: '验证码' })
  readonly smsCode: string;
}

export class RegisterCodeDto {
  /**
   * 手机号（系统唯一）
   */
  @Matches(regMobileCN, { message: '请输入正确手机号' })
  @IsNotEmpty({ message: '请输入手机号' })
  @ApiProperty({ example: '18715147473', description: '手机号' })
  readonly phoneNumber: string;

  @IsNotEmpty({ message: '请输入验证码ID' })
  @ApiProperty({ example: 'GaBUGhJzESU=', description: '验证码ID' })
  readonly captchaId: string;

  @IsNotEmpty({ message: '请输入验证码' })
  @ApiProperty({ example: '0000', description: '验证码' })
  readonly captchaCode: string;
}

export class RegisterDto {
  /**
   * 手机号，唯一
   */
  @Matches(regMobileCN, { message: '请输入正确手机号' })
  @IsNotEmpty({ message: '请输入手机号' })
  @ApiProperty({ example: '18715147473' })
  readonly phoneNumber: string;

  /**
   * 用户名
   */
  @IsNotEmpty({ message: '请输入用户昵称' })
  @IsString({ message: '名字必须是 String 类型' })
  @ApiProperty({ example: 'xp', description: '用户名' })
  readonly name: string;

  /**
   * 用户密码
   */
  @IsNotEmpty({ message: '请输入密码' })
  @ApiProperty({ example: '888888', description: '密码' })
  readonly password: string;

  /**
   * 二次输入密码
   */
  @IsNotEmpty({ message: '请再次输入密码' })
  @ApiProperty({ example: '888888', description: '确认密码' })
  readonly passwordRepeat: string;
}

export class UserInfoDto {
  /**
   * 手机号（系统唯一）
   */
  @Matches(regMobileCN, { message: '请输入正确手机号' })
  @IsNotEmpty({ message: '请输入手机号' })
  @ApiProperty({ example: '187151417573', description: '手机号' })
  readonly phoneNumber: string;

  @ApiProperty({ example: 'xp', description: '用户名' })
  @IsNotEmpty()
  name: string;

  @ApiProperty({ example: '123456', description: '密码' })
  @IsNotEmpty()
  password: string;

  @ApiProperty({ example: '15906475@qq.com', description: '邮箱' })
  @IsNotEmpty()
  email: string;

  @ApiProperty({ example: 'cookieboty', description: '头像' })
  @IsNotEmpty()
  avatar: string;

  @ApiProperty({ example: 'frontend', description: '工作' })
  @IsNotEmpty()
  job: string;

  @ApiProperty({ example: '前端开发工程师', description: '工作名称' })
  @IsNotEmpty()
  jobName: string;

  @ApiProperty({ example: 'cookieboty', description: '组织' })
  @IsNotEmpty()
  organization: string;

  @ApiProperty({ example: 'beijing', description: '位置' })
  @IsNotEmpty()
  location: string;

  @ApiProperty({ example: 'cookieboty', description: '个人网站' })
  @IsNotEmpty()
  personalWebsite: string;

  @ApiProperty({ example: '{}' })
  permissions?: object | [];

  salt?: string;
}
export class TokenDto {
  @ApiProperty({ description: 'token' })
  readonly token: string;
}

export class RegisterCodeItem {
  /**
   * 手机号
   */
  mobile: string;
}

export class UserInfoItem {
  /**
   * 用户id
   */
  id: number;

  /**
   * 创建时间
   */
  createTime: Date;

  /**
   * 更新时间
   */
  updateTime: Date;

  /**
   * 手机号
   */
  mobile: string;
}

export class UserInfoVO {
  info: UserInfoItem;
}

// export class UserInfoSuccessVO extends SuccessVO {
//     data: UserInfoVO
// }
